const recursion = (trees, childrenName, callBack, parent = null) => {
  for (let i = 0; i < trees.length; i++) {
    const tree = trees[i];
    callBack(tree, parent);
    if (tree[childrenName]) {
      recursion(tree[childrenName], childrenName, callBack, tree);
    }
  }
};

export default recursion;
